package com.atguigu.gmall.cart.mapper;

import com.atguigu.gmall.model.cart.CartInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * projectName: gmall
 *
 * @author: 陈鹏
 * time: 2022/10/7 15:42 星期五
 * description: 购物车的mapper层
 */
@Mapper
public interface CartInfoMapper extends BaseMapper<CartInfo> {

    /**
     * 该用户全部选中购物车数据
     * @param status
     * @param username
     * @return
     */
    @Update("UPDATE cart_info SET is_checked = #{status} WHERE user_id = #{username}")
    public int all(@Param("status") Short status,
                   @Param("username")String username);

    /**
     * 该用户选中单个购物车数据
     * @param status
     * @param username
     * @param id
     * @return
     */
    @Update("UPDATE cart_info SET is_checked = #{status} WHERE user_id = #{username} and id = #{id}")
    public int one(@Param("status")Short status,
                   @Param("username") String username,
                   @Param("id")Long id);
}
